home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / mountoverflowtmp < prev    next >
Text File  |  2008-10-14  |  1KB  |  56 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          mountoverflowtmp
  4. # Required-Start:    mountall-bootclean
  5. # Required-Stop:     umountfs
  6. # Default-Start:     S
  7. # Default-Stop:      0 6
  8. # Short-Description: mount emergency /tmp.
  9. # Description:       Mount a tmpfs on /tmp if there would
  10. #                    otherwise be too little space to log in.
  11. ### END INIT INFO
  12.  
  13. . /lib/init/vars.sh
  14. . /lib/lsb/init-functions
  15.  
  16. set -e
  17.  
  18. defs=/etc/default/mountoverflowtmp
  19. test ! -f "$defs" || . "$defs"
  20.  
  21. : ${MINTMPKB:=1024}
  22. if test "$MINTMPKB" = "0"; then exit 0; fi
  23.  
  24. case "$1" in
  25.   start)
  26.     [ "$VERBOSE" != no ] && log_action_begin_msg "Checking minimum space in /tmp"
  27.     df="`df -kP /tmp |grep -v Filesystem`"
  28.     set -- $df
  29.     avail="$4"
  30.     [ "$VERBOSE" != no ] && log_action_end_msg 0
  31.     if test $avail -lt "$MINTMPKB"; then
  32.         log_action_begin_msg "Mounting emergency tmpfs on /tmp"
  33.         mount -t tmpfs -o size=1048576,mode=1777 overflow /tmp
  34.         log_action_end_msg 0
  35.     fi
  36.     ;;
  37.   restart|reload|force-reload)
  38.     echo "Error: argument '$1' not supported" >&2
  39.     exit 3
  40.     ;;
  41.   stop)
  42.     if LANG=C LC_ALL=C mount | \
  43.         grep '^overflow on /tmp type tmpfs' >/dev/null; then
  44.         log_action_begin_msg "Unmounting any overflow tmpfs from /tmp"
  45.         umount overflow
  46.         log_action_end_msg 0
  47.     fi
  48.     ;;
  49.   *)
  50.     echo "Usage: mountoverflowtmp [start|stop]" >&2
  51.     exit 3
  52.     ;;
  53. esac
  54.  
  55. :
  56.